package com.qiyebox.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qiyebox.common.annotation.Log;
import com.qiyebox.common.enums.BusinessType;
import com.qiyebox.system.domain.MeetingText;
import com.qiyebox.system.service.IMeetingTextService;
import com.qiyebox.common.core.controller.BaseController;
import com.qiyebox.common.core.domain.AjaxResult;
import com.qiyebox.common.utils.poi.ExcelUtil;
import com.qiyebox.common.core.page.TableDataInfo;

/**
 * 会议字幕Controller
 * 
 * @author qiyebox
 * @date 2025-02-14
 */
@Controller
@RequestMapping("/system/text")
public class MeetingTextController extends BaseController
{
    private String prefix = "system/text";

    @Autowired
    private IMeetingTextService meetingTextService;

    @RequiresPermissions("system:text:view")
    @GetMapping()
    public String text()
    {
        return prefix + "/text";
    }

    /**
     * 查询会议字幕列表
     */
    @RequiresPermissions("system:text:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MeetingText meetingText)
    {
        startPage();
        List<MeetingText> list = meetingTextService.selectMeetingTextList(meetingText);
        return getDataTable(list);
    }

    /**
     * 导出会议字幕列表
     */
    @RequiresPermissions("system:text:export")
    @Log(title = "会议字幕", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MeetingText meetingText)
    {
        List<MeetingText> list = meetingTextService.selectMeetingTextList(meetingText);
        ExcelUtil<MeetingText> util = new ExcelUtil<MeetingText>(MeetingText.class);
        return util.exportExcel(list, "会议字幕数据");
    }

    /**
     * 新增会议字幕
     */
    @RequiresPermissions("system:text:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会议字幕
     */
    @RequiresPermissions("system:text:add")
    @Log(title = "会议字幕", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MeetingText meetingText)
    {
        return toAjax(meetingTextService.insertMeetingText(meetingText));
    }

    /**
     * 修改会议字幕
     */
    @RequiresPermissions("system:text:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MeetingText meetingText = meetingTextService.selectMeetingTextById(id);
        mmap.put("meetingText", meetingText);
        return prefix + "/edit";
    }

    /**
     * 修改保存会议字幕
     */
    @RequiresPermissions("system:text:edit")
    @Log(title = "会议字幕", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MeetingText meetingText)
    {
        return toAjax(meetingTextService.updateMeetingText(meetingText));
    }

    /**
     * 删除会议字幕
     */
    @RequiresPermissions("system:text:remove")
    @Log(title = "会议字幕", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(meetingTextService.deleteMeetingTextByIds(ids));
    }
}
